<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ count }}</strong></span
    >
    <ul class="filters" @click="fn">
      <li>
        <a
          :class="{ selected: isSel === 'all' }"
          href="javascript:;"
          @click="isSel = 'all'"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: isSel === 'no' }"
          href="javascript:;"
          @click="isSel = 'no'"
          >未完成</a
        >
      </li>
      <li>
        <a
          :class="{ selected: isSel === 'yes' }"
          href="javascript:;"
          @click="isSel = 'yes'"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="clearFn">清除已完成</button>
  </footer>
</template>

<script>
export default {
  name: "TodoFooter",
  props: ["farr"],
  computed: {
    count() {
      // return this.farr.length;
      return this.$store.getters.showType.length;
    },
  },
  data() {
    return {
      //点击底部切换 – 点谁谁有边框
      isSel: "all", //all, yes, no
    };
  },
  methods: {
    fn() {
      this.$store.commit("typestr", this.isSel);
      // console.log(111);
    },
    clearFn() {
      this.$store.commit("clearFun");
      // console.log(222);
    },
  },
};
</script>